package com.springboot.mybatis.mapper;

import com.springboot.mybatis.model.User;
import org.apache.ibatis.annotations.*;

/**
 * @author liuwei
 * @version 2017/7/17 上午12:56
 * @modified TODO
 * @description 功能描述
 * @see
 * @since 1.0
 */
@Mapper
public interface UserMapper {

    @Select("select * from t_user where id=#{id}")
    @Results({
            @Result(property = "id" , column = "id"),
            @Result(property = "name" , column = "name"),
            @Result(property = "age" , column = "age"),
            @Result(property = "sex" , column = "sex"),
            @Result(property = "createTime" , column = "createTime")
    })
    User findById(@Param("id") Long id);

    @Insert("insert into t_user(name,age,sex,createTime) values(#{name,jdbcType=VARCHAR},#{age,jdbcType=INTEGER},#{sex,jdbcType=INTEGER},NOW())")
    @Options(useGeneratedKeys = true)
    int insert(User user);
}
